﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcProject.Models;

namespace MvcProject.Controllers
{
    public class RatedUsedController : Controller
    {
        private BaseModels db = new BaseModels();
        //
        // GET: /RatedUsed/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /RatedUsed/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /RatedUsed/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /RatedUsed/Create

        [HttpPost]
        public ActionResult Create(MaterialUseRecord dinner)
        {
            if (ModelState.IsValid)
                try
                {
                    UpdateModel(dinner);
                    dinner.CreateDate = System.DateTime.Now;
                    dinner.CreateUserName = "ywx";
                    db.Add(dinner);
                    db.Save();
                    return RedirectToAction("Details", new { id = dinner.TeamId });
                }
                catch (Exception e)
                {
                    return View(dinner);
                }
            return View(dinner);
        }
        
        //
        // GET: /RatedUsed/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /RatedUsed/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /RatedUsed/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /RatedUsed/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
